#!/bin/sh
if [ $# != 2 ]; then
    echo "sh get-android-mem.sh deviceId appName"
    exit 1;
fi

deviceId=$1
appName=$2

currentDir=$(cd "$(dirname "$0")"; pwd)
echo "current dir : "$currentDir
datDir=$currentDir/../../../target/android-info/mem/dat
htmlDir=$currentDir/../../../target/android-info/mem/html

if [ ! -d "$datDir" ]; then
    mkdir -p $datDir
fi
if [ ! -d "$htmlDir" ]; then
    mkdir -p $htmlDir
fi

while true
do
    adb -s $deviceId shell dumpsys meminfo com.${appName} | sed -n 9p | awk '{print $3}'  >> $datDir/mem.dat
sleep 3
done